package com.emser.unc.restlet.manager;

import java.io.Serializable;
import java.util.concurrent.Callable;

import org.restlet.data.ChallengeScheme;
import org.restlet.resource.ClientResource;

import com.emser.unc.restlet.LocationResource;
import com.emser.unc.serializable.LocationDTO;

public class LocationTransferManager extends TransferManager implements Callable<String>{
	
	private LocationDTO locationDTO;
	private LocationResource locationResource;
	private Boolean response;

	@Override
	public void setParams(String url, String userRest, String PassRest) {
		// TODO Auto-generated method stub
		locationDTO = new LocationDTO();
		ClientResource cr = new ClientResource(url);
		cr.setRequestEntityBuffering(true);
		cr.setChallengeResponse(ChallengeScheme.HTTP_BASIC, userRest, PassRest);
		locationResource = cr.wrap(LocationResource.class);
	}

	@Override
	public void setRequest(Serializable objectDTO) {
		// TODO Auto-generated method stub
		this.locationDTO = (LocationDTO)objectDTO;
	}

	@Override
	public Serializable getResponse() {
		// TODO Auto-generated method stub
		return response;
	}

	@Override
	public String call() throws Exception {
		// TODO Auto-generated method stub
		response = Boolean.FALSE;
		response = locationResource.store(locationDTO);
		return null;
	}

}
